home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / winlib.lzh / WINLIB / XVDI.C < prev   
Encoding:
C/C++ Source or Header  |  1994-03-26  |  5.5 KB  |  217 lines

  1. /********************************************************************
  2.  *                                                                    *
  3.  *    VDI stuff                                                        *
  4.  *                                                                    *
  5.  *    Copyright (c) Clever Bits and Bitgate Software 1993 - 1994        *
  6.  *    All Rights Reserved.                                            *
  7.  *                                                                    *
  8.  *    This module offers extensions to calling normal VDI commands,    *
  9.  *    with easier-to-memorize calls.  Although we don't attack ALL of *
  10.  *    the tiny commands, the commands we do call are the ones we think*
  11.  *    are the most useful ones.  Still needs a bit of work, though.    *
  12.  *                                                                    *
  13.  ********************************************************************
  14.  *                                                                    *
  15.  *    Update log:                                                        *
  16.  *                                                                    *
  17.  *    [31.10.93] Karl A. 0ygard                                        *
  18.  *        point                    - moved from extndobj.c                *
  19.  *        line                    - moved from extndobj.c                *
  20.  *        point                    - greatly optimized                    *
  21.  *        box                        - greatly optimized                    *
  22.  *        box_fill                - optimised                            *
  23.  *        XVDI_NewTempVDIHandle    - added for graphics routines        *
  24.  *        XVDI_DeleteVDIHandle    - added for graphics routines        *
  25.  *                                                                    *
  26.  ********************************************************************/
  27.  
  28. #include <vdi.h>        /* Standard VDI bindings */
  29.  
  30. #include "winlib.h"        /* WinLIB header file */
  31.  
  32. #ifndef __XVDI__
  33. #define __XVDI__
  34. #endif
  35.  
  36. XVDIVARS SaveHandles;
  37.  
  38. GLOBAL void line(int x1, int y1, int x2, int y2)
  39. {
  40.     int pxyarray[4];
  41.  
  42.     pxyarray[0] = x1;
  43.     pxyarray[1] = y1;
  44.     pxyarray[2] = x2;
  45.     pxyarray[3] = y2;
  46.  
  47.     v_pline(VDIhandle, 2, pxyarray);
  48. }
  49.  
  50. GLOBAL void point(int x, int y, int color)
  51. {
  52.     int pxyarray[2];
  53.  
  54.     pxyarray[0] = x;
  55.     pxyarray[1] = y;
  56.  
  57.     vsm_color(VDIhandle, color);
  58.     v_pmarker(VDIhandle, 1, pxyarray);
  59. }
  60.  
  61. GLOBAL void box(int x, int y, int w, int h, int color)
  62. {
  63.     int pxyarray[10];
  64.  
  65.     pxyarray[2] = pxyarray[4] = (pxyarray[0] = pxyarray[6] = pxyarray[8] = x) + w;
  66.     pxyarray[5] = pxyarray[7] = (pxyarray[1] = pxyarray[3] = pxyarray[9] = y) + h;
  67.  
  68.     vsl_color(VDIhandle, color);
  69.     v_pline(VDIhandle, 5, pxyarray);
  70. }
  71.  
  72. GLOBAL void box_fill(int x, int y, int w, int h, int color)
  73. {
  74.     int pxyarray[4];
  75.  
  76.     pxyarray[2] = (pxyarray[0] = x) + w;
  77.     pxyarray[3] = (pxyarray[1] = y) + h;
  78.  
  79. /*    vsf_interior(VDIhandle, 1); */
  80.     vsf_color(VDIhandle, color);
  81.     vsl_color(VDIhandle, color);
  82.     v_bar(VDIhandle, pxyarray);
  83. }
  84.  
  85. GLOBAL void fillarea(int x1, int y1, int x2, int y2, int interior, int color)
  86. {
  87.     int pxyarray[4];
  88.  
  89.     pxyarray[0] = x1;
  90.     pxyarray[1] = y1;
  91.     pxyarray[2] = x2;
  92.     pxyarray[3] = y2;
  93.  
  94.     vsf_interior(VDIhandle, interior);
  95.     vsf_color(VDIhandle, color);
  96.  
  97.     v_fillarea(VDIhandle, 2, pxyarray);
  98. }
  99.  
  100. GLOBAL void fill(int x, int y, int color)
  101. {
  102.     vsf_interior(VDIhandle, 1);
  103.     vsf_color(VDIhandle, color);
  104.  
  105.     v_contourfill(VDIhandle, x, y, color);
  106. }
  107.  
  108. GLOBAL void reset_vdi()
  109. {
  110.     vsf_interior(VDIhandle, 0);
  111.     vsf_color(VDIhandle, 1);
  112.     vsl_color(VDIhandle, 1);
  113.     vst_color(VDIhandle, 1);
  114. /*    vsl_width(VDIhandle, 1);
  115.     vst_effects(VDIhandle, 0);
  116.     vsf_perimeter(VDIhandle, 0); */
  117.     vswr_mode(VDIhandle, MD_REPLACE);
  118. }    
  119.  
  120. GLOBAL void restore_clip()
  121. {
  122.     int pxyarray[4];
  123.  
  124.     pxyarray[0] = desk.g_x;
  125.     pxyarray[1] = desk.g_y;
  126.     pxyarray[2] = desk.g_w;
  127.     pxyarray[3] = desk.g_h;
  128.  
  129.     vs_clip(VDIhandle, 1, pxyarray);
  130. }
  131.  
  132. GLOBAL void LockScreenUpdate()
  133. {
  134.     wind_update(BEG_UPDATE);
  135.     wind_update(BEG_MCTRL);
  136. }
  137.  
  138. GLOBAL void UnlockScreenUpdate()
  139. {
  140.     wind_update(END_UPDATE);
  141.     wind_update(END_MCTRL);
  142. }
  143.  
  144. GLOBAL void XVDI_SaveHandles(void)
  145. {
  146.     int i;
  147.  
  148.     vqt_attributes(VDIhandle, SaveHandles.textattributes);
  149.     vqf_attributes(VDIhandle, SaveHandles.fillattributes);
  150.     vql_attributes(VDIhandle, SaveHandles.lineattributes);
  151.  
  152.     vswr_mode(VDIhandle, MD_REPLACE);
  153.  
  154.     vst_color(VDIhandle, BLACK);
  155.     vst_rotation(VDIhandle, 0);
  156.     vst_height(VDIhandle, 6, &i, &i, &i, &i);
  157.     vst_effects(VDIhandle, 0);
  158.  
  159.     vsf_interior(VDIhandle, FIS_SOLID);
  160.     vsf_color(VDIhandle, BLACK);
  161.     vsf_style(VDIhandle, 7);
  162.     vsf_perimeter(VDIhandle, 0);
  163.  
  164.     vsl_type(VDIhandle, 1);
  165.     vsl_color(VDIhandle, BLACK);
  166.     vsl_width(VDIhandle, 1);
  167. }
  168.  
  169. GLOBAL void XVDI_RestoreHandles(void)
  170. {
  171.     int    i;
  172.  
  173.     vst_color(VDIhandle, SaveHandles.textattributes[1]);
  174.     vst_rotation(VDIhandle, SaveHandles.textattributes[2]);
  175.     vst_alignment(VDIhandle, SaveHandles.textattributes[3], SaveHandles.textattributes[4], &i, &i);
  176.     vst_effects(VDIhandle, 0);
  177.  
  178. /* Why they save the writing mode three times I may never know, but
  179.    they do.  Use the text attributes, since it's text we're using
  180.    for the drawing mode.  If not, change the writing mode in your
  181.    own routine. */
  182.  
  183.     vswr_mode(VDIhandle, SaveHandles.textattributes[5]);
  184. /*    vswr_mode(VDIhandle, SaveHandles.fillattributes[3]); */
  185. /*    vswr_mode(VDIhandle, SaveHandles.lineattributes[2]); */
  186.  
  187.     vst_height(VDIhandle, SaveHandles.textattributes[7], &i, &i, &i, &i);
  188.  
  189.     vsf_interior(VDIhandle, SaveHandles.fillattributes[0]);
  190.     vsf_color(VDIhandle, SaveHandles.fillattributes[1]);
  191.     vsf_style(VDIhandle, SaveHandles.fillattributes[2]);
  192.     vsf_perimeter(VDIhandle, SaveHandles.fillattributes[4]);
  193.  
  194.     vsl_type(VDIhandle, SaveHandles.lineattributes[0]);
  195.     vsl_color(VDIhandle, SaveHandles.lineattributes[1]);
  196.     vsl_width(VDIhandle, SaveHandles.lineattributes[5]);
  197. }
  198.  
  199. GLOBAL void XVDI_RestoreForGEM(void)
  200. {
  201.     int    i;
  202.  
  203.     vst_color(VDIhandle, BLACK);
  204.     vst_rotation(VDIhandle, 0);
  205.     vst_effects(VDIhandle, 0);
  206.  
  207.     vswr_mode(VDIhandle, MD_REPLACE);
  208.     vst_height(VDIhandle, 6, &i, &i, &i, &i);
  209.  
  210.     vsf_interior(VDIhandle, FIS_HOLLOW);
  211.     vsf_color(VDIhandle, WHITE);
  212.     vsf_style(VDIhandle, 7);
  213.     vsf_perimeter(VDIhandle, 1);
  214.  
  215.     vsl_color(VDIhandle, BLACK);
  216.     vsl_width(VDIhandle, 1);
  217. }